/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.arg.deploy.webapp.template.ctrl;

import com.arg.deploy.webapp.common.MainPageController;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Button;

/**
 *
 * @author sorasaks
 */
public class AdminMainCtrl extends MainPageController {
    
    private Button btnSignout;
    
    public AdminMainCtrl() {
        super("Deploy ::: Admin Control", Boolean.FALSE);
    }

    @Override
    public void doAfterCompose(Component comp) throws Exception {
        super.doAfterCompose(comp); //To change body of generated methods, choose Tools | Templates.
        initailEventListener();
    }
    
    private void initailEventListener() {
        btnSignout.addEventListener(Events.ON_CLICK, new Signout());
    }

    private class Signout implements EventListener {

        @Override
        public void onEvent(Event t) throws Exception {
            Executions.getCurrent().getSession().setAttribute(USER_PERMISSION, null);
            Executions.sendRedirect("/");
        }
    }
    
}
